﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using NUnit.Framework;

namespace ApplicationLayer
{
#if (DEBUG)
    [TestFixture]
#endif
    public class FreqUsed
    {
        public static bool isInRectangle(MouseState ms, Rectangle rect)
        {
            if (ms.X <= rect.Right && ms.X >= rect.Left && ms.Y <= rect.Bottom && ms.Y >= rect.Top)
            {
                return true;
            }
            return false;
        }
        public static void DrawSquare(Rectangle r, int border, Color color, SpriteBatch spriteBatch, Texture2D texPixel)
        {
            spriteBatch.Draw(texPixel, new Rectangle(r.Left, r.Top, r.Width, border), color);
            spriteBatch.Draw(texPixel, new Rectangle(r.Left + r.Width - border, r.Top, border, r.Height), color);
            spriteBatch.Draw(texPixel, new Rectangle(r.Left, r.Top + r.Height - border, r.Width, border), color);
            spriteBatch.Draw(texPixel, new Rectangle(r.Left, r.Top, border, r.Height), color);
        }
        public static void DrawSquareWithFill(Rectangle r, int border, Color borderColor, Color fillColor, SpriteBatch spriteBatch, Texture2D texPixel)
        {
            spriteBatch.Draw(texPixel, new Rectangle(r.Left + border, r.Top + border, r.Width - 2 * border, r.Height - 2 * border), fillColor);
            DrawSquare(r, border, borderColor, spriteBatch, texPixel);
        }
#if (DEBUG)
        [Test]
        public void Test01_CheckMouse()
        {
            MouseState ms = new MouseState(10, 10, 0, ButtonState.Pressed, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released);
            Assert.IsTrue(ms.LeftButton == ButtonState.Pressed);
        }
        [Test]
        public void Test02_CheckMouseInRectangle()
        {
            MouseState ms = new MouseState(10, 10, 0, ButtonState.Pressed, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released);
            Rectangle r = new Rectangle(0, 0, 50, 50);
            Assert.IsTrue(isInRectangle(ms, r));
        }
        [Test]
        public void Test03_CheckMouseInRectangleAndPressed()
        {
            MouseState ms = new MouseState(10, 10, 0, ButtonState.Pressed, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released);
            Rectangle r = new Rectangle(0, 0, 50, 50);
            Assert.IsTrue(isInRectangle(ms, r) && ms.LeftButton == ButtonState.Pressed);
        }
#endif
    }
}
